public class demo3 {
    public static void main(String[] args) {
        Object object1 = new Object();
        Object object2 = new Object();
        Thread t1 = new Thread(()->{
            synchronized (object1){
                System.out.println("t1 第一次");
                synchronized (object2){
                    System.out.println("t1 加锁成功");
                };
            };

        });

        Thread t2 = new Thread(()->{
            synchronized (object2){
                System.out.println("t2 第一次");
                synchronized (object1){
                    System.out.println("t2 加锁成功");
                };
            };

        });
        t1.start();
        t2.start();
    }
}
